#### Start of system configuration section. ####

srcdir =	@srcdir@

ifeq ($(srcdir),.)
srcdir = ../..
endif

VPATH :=	$(srcdir)

# Common prefix for machine-independent installed files.
prefix =	@prefix@

# Common prefix for machine-dependent installed files.
exec_prefix =	@exec_prefix@

bindir =	$(exec_prefix)/bin
libdir =	$(exec_prefix)/Sys/libs

INSTALL =	@INSTALL@
INSTALL_DATA =	@INSTALL_DATA@

CC =		@CC@

CFLAGS =	@CFLAGS@
LDFLAGS =	@LDFLAGS@

RANLIB =	@RANLIB@
AR =		ar

#### End system configuration section ####

ifdef CATENATE
DEBUG_FLAG =	-g
else
DEBUG_FLAG =	
endif

# I *love* GNU make!
define catenate
/bin/echo -n creating $@...
/bin/echo "$(^:%=#include \"%\"\n)" >$@
/bin/echo done
endef

FLAVOR_CFLAGS =	-m$(CPU) -m$(FPU)
ALL_CFLAGS =	$(CFLAGS) $(FLAVOR_CFLAGS) $(OTHER_CFLAGS) $(DEBUG_FLAG) $(INCS)

INCS =		-I$(srcdir) -I$(srcdir)/../library -I$(srcdir)/../include
LIB =		libstdio.a

.c.o:
		$(CC) $(ALL_CFLAGS) -c $< -o $@

SRC =		clrerr.c fclose.c fdopen.c feof.c ferror.c fflush.c fgetc.c \
		fgetline.c fgetpos.c fgets.c fileno.c findfp.c flags.c \
		fopen.c fprintf.c fpurge.c fputc.c fputs.c fread.c freopen.c \
		fscanf.c fseek.c fsetpos.c ftell.c funopen.c fvwrite.c fwalk.c \
		fwrite.c getc.c getchar.c gets.c getw.c makebuf.c perror.c \
		printf.c putc.c putchar.c puts.c putw.c refill.c rewind.c \
		rget.c scanf.c setbuf.c setbuffer.c setvbuf.c snprintf.c \
		sprintf.c sscanf.c stdio.c tempnam.c tmpfile.c tmpnam.c \
		ungetc.c vfprintf.c vfscanf.c vprintf.c vscanf.c \
		vsnprintf.c vsprintf.c vsscanf.c wbuf.c wsetup.c

OBJ =		$(SRC:.c=.o)

ifdef CATENATE
ALL =		all.o
else
ALL =		$(OBJ)
endif

$(LIB) :	$(ALL)
		rm -f $@
		$(AR) rv $@ $(ALL)
		$(RANLIB) $@

all.c:		$(SRC)
		@$(catenate)

clean:
		rm -rf 680?0

clobber:	clean
		rm -f Makefile

fdopen.o :	local.h
fclose.o :	local.h
fflush.o :	local.h
fwrite.o :	local.h fvwrite.h
findfp.o :	local.h
fpurge.o :	local.h
fwalk.o :	local.h
funopen.o :	local.h
fgetline.o :	local.h
freopen.o :	local.h
fseek.o :	local.h
ftell.o :	local.h
fvwrite.o :	local.h fvwrite.h
fputs.o :	fvwrite.h
fopen.o :	local.h
makebuf.o :	local.h
puts.o :	fvwrite.h
putw.o :	fvwrite.h
setbuf.o :	local.h
refill.o :	local.h
setvbuf.o :	local.h
sprintf.o :	local.h
sscanf.o :	local.h
vfscanf.o :	local.h floatio.h
stdio.o :	local.h
vfprintf.o :	local.h fvwrite.h floatio.h
ungetc.o :	local.h
wbuf.o :	local.h
wsetup.o :	local.h
